package com.px.chapter_Dec_1.textt;

import java.util.Queue;

public class LittleMoth {
    public static String outSpect(String io) {
        char[] ii=io.toCharArray();
        int c=0,o=0;
        for (int a=0;a<ii.length-1;a++){
            char s=' ';
            if (ii[a]==s){
                c=a;
                break;
            }
        }
        for (int a=ii.length-1;a>=0;a--){
            char s=' ';
            if(ii[a]==s){
                o=a;
                break;
            }
        }
        return io.substring(c+1,o);
    }
    public static String  RangeTransform(String instring,int start,int end) {

        char[] ii=instring.toCharArray();
        int d=end-start;
        for (int a=start,dd=d/2+1,cc=end;a<=end;a++,dd--,cc--){
            if (dd==0)break;
            char o=ii[cc];
            ii[cc]=ii[a];
            ii[a]=o;

        }
        return String.valueOf(ii);
    }
    public static int FoundCount(String string,String selectstring) {

        int a=selectstring.length(),b=0;
        while (string.indexOf(selectstring)!=-1){
            b++;
            string=string.substring(string.indexOf(selectstring)+a,string.length());
        }
        return b;
    }
    public static String maxSameSub(String str1,String str2){
        if (str1.length()<str2.length()){
            String t=str1;str1=str2;str2=t;
        }
        int maxLen=str2.length();
        while (maxLen>0){
            for (int i=0;i+maxLen<str2.length();i++){
                String sub=str2.substring(i,i+maxLen+1);
                if (str1.indexOf(sub)>=0)return sub;

            }
            maxLen--;
        }
        return "";
    }


}
